<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use app\models\ArcTrain;

/* @var $this yii\web\View */
/* @var $model app\models\ArcAndroid */

$this->title = "";
$this->params['breadcrumbs'][] = ['label' => '质检机器人', 'url' => ['index']];
$this->params['breadcrumbs'][] = '查看';
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];

?>
<a id="back" class="btn btn-default pull-left" href="index" ><i class="fa fa-backward"></i> 返回列表页</a>
<div class="help-block" style="height: 30px"></div>
<div class="arc-android-view">
    <h3><?='质检机器人名称:'.$model->name?></h3>

    <h4>以下是详细内容：</h4>
    <p>
        <?= Html::a('修改', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('删除', ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => '你确定要删除该条文件吗?',
                'method' => 'post',
            ],
        ]) ?>
    </p>

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            'name',
            'number',
            'onetime_num',
            'http:ntext',
            'parms:ntext',
            [   'attribute' =>'',
                'value'=>
                function($model){
                    $arcTrainModel = new ArcTrain();//训练的模型
                    $res = $arcTrainModel->findAll(['arc_android'=>$model->id]);
                    sort($res);
                    $res = array_reverse($res);
                    $resStr = '';
                    foreach ($res as $k=>$v){
                        $sql = 'select id from arc_train where arc_android='.$model->id . ' and arc_android_num='.$v->arc_android_num;
                        $arcTrainModels = $arcTrainModel->getDb()->createCommand($sql)->queryOne();//得到该机器人现在的总数量
                        $resStr = '<a id="modal_'.$v->arc_android_num.'"
                            class="btn btn-default btn-flat" 
                            href="../thing-record-file/classify-continue?serialNumber='.$v->arc_android_num.'&arcAndroidId='.$model->id.'&arcTrainId='.$arcTrainModels['id'].' 
                            title="请点击该机器人进行修改以及查看" data-toggle="modal"
                            data-target="#create-modal">机器人'.$v->arc_android_num.'</a>'.$resStr;
                    }
                    return $resStr;
                },
                'label'=>'<div id="android_id">拥有的机器人</div>'
            ],
        ],
        // 'template' 属性调整表格每一行的样式
        'template' => '<tr><th style="width: 120px;">
        					{label}</th>
            		<td style="word-wrap:break-word;
            		word-break:break-all;
            		max-height:300px;
            		display: -webkit-box;-webkit-line-clamp: 6;
            		-webkit-box-orient: vertical;
            		overflow: auto;">
            		<div style="overflow:auto">
            		{value}
            		</div>
            		</td>
            		</tr>', 
    ]) ?>
    <?= $this->render('/common/dialog_iframe')?>
    
    <script type="text/javascript">
        	var labelButton = $("#android_id").parent().next().children();
        	var labelButtonText = labelButton.text();
        	labelButton.html(labelButtonText);
    </script>

</div>
